package share

import (
	"oc_saas/glo"
	share_req "oc_saas/model/req/share"
	share_res "oc_saas/model/res/share"
	"oc_saas/service/share"
	"oc_saas/utils/tool"

	"github.com/gin-gonic/gin"
)

// 公共
type Share struct{}

// 登录
func (*Share) Login(c *gin.Context) {
	var body share_req.CommonLogin
	if err := c.ShouldBindJSON(&body); err != nil {
		panic(err)
	}
	if err := glo.OC_VALID.Struct(body); err != nil {
		panic(err)
	}
	// 生成token
	token := share.ShareService.Login(&body)
	tool.OkWithData(&share_res.AccessToken{AccessToken: token}, c)
}

// 退出登录
func (*Share) LogOut(c *gin.Context) {
	tool.Ok(c)
}

var ShareController = new(Share)
